package com.ai.mapper.made;

import com.ai.entity.made.Slabs;
import com.ai.entity.made.Unusual;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author chen
 * @since 2023-03-28 11:12:30
 */
public interface UnusualMapper extends BaseMapper<Unusual> {

    @Select("SELECT\n" +
            "\tslab_num,\n" +
            "\tSUM( CASE `un_status` WHEN 1 THEN count ELSE 0 END ) AS unusual1,\n" +
            "\tSUM( CASE `un_status` WHEN 2 THEN count ELSE 0 END ) AS unusual2,\n" +
            "\tSUM( CASE `un_status` WHEN 3 THEN count ELSE 0 END ) AS unusual3,\n" +
            "\tSUM( CASE `un_status` WHEN 4 THEN count ELSE 0 END ) AS unusual4,\n" +
            "\tSUM( CASE `un_status` WHEN 5 THEN count ELSE 0 END ) AS unusual5 \n" +
            "FROM\n" +
            "\t(select slab_num,status un_status,SUM(number) count from t_unusual where slab_num = #{slabNum} GROUP BY status ) u;")
    Slabs getUnusual(@Param("slabNum") String slabNum);
}
